import javax.swing.ImageIcon;

public class Card implements Comparable<Card>
{
	private int faceValue;
	private int value;
	private ImageIcon icon;
	private String color;

	
	public Card()
	{
		super();
	}

	/**
	 * The face value is the number on the card The point value represents what
	 * each card is worth
	 * 
	 * @param faceValue
	 *            the value of the card
	 * @param value
	 *            the point value given to the card
	 * @param icon
	 *            the path to where the icon for the card is stored
	 * @see Deck
	 */
	public Card(int faceValue, int value, String color, ImageIcon icon)
	{
		this.faceValue = faceValue;
		this.value = value;
		this.color = color;
		this.icon = icon;
	}

	/**
	 * 
	 * @return The value of the card
	 */
	public int getFace()
	{
		return faceValue;
	}

	/**
	 * 
	 * @return the point value of the card
	 */
	public int getValue()
	{
		return value;
	}

	/**
	 * 
	 * @return the path for the icon
	 */
	public ImageIcon getIcon()
	{
		return icon;
	}

	/**
	 * Set path for icon
	 * 
	 * @param icon
	 */
	public void setIcon(ImageIcon icon)
	{
		this.icon = icon;
	}

	/**
	 * Set the face value for a card
	 * 
	 * @param face
	 */
	public void setFace(int face)
	{
		this.faceValue = face;
	}

	/**
	 * 
	 * @return
	 */
	public String getColor()
	{
		return color;
	}

	/**
	 * 
	 * @param color
	 */

	public void setColor(String color)
	{
		this.color = color;
	}

	/**
	 * The is the compare to method. This method compares the color as well as
	 * the face value
	 */
	@Override
	public int compareTo(Card c1)
	{

		if (this == c1)
			return 0;
		if (this.getColor().equalsIgnoreCase(c1.getColor()))
			return 0;
		if (this.getFace() == c1.getFace())
			return 0;

		else return 1;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((color == null) ? 0 : color.hashCode());
		result = prime * result + faceValue;
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Card other = (Card) obj;
		if (color == null)
		{
			if (other.color != null)
				return false;
		} else if (!color.equals(other.color))
			return false;
		if (faceValue != other.faceValue)
			return false;
		return true;
	}

	/**
	 * The toString method.
	 * 
	 */
	@Override
	public String toString()
	{
		return "[faceValue:" + getFace() + ", value:" + getValue()
				+ ", color:\"" + getColor() + "\", icon:\"" + getIcon() + "\"]";
	}

}
